const { defineConfig } = require('@vue/cli-service')
const packageName = require('./package.json').name;

let path = require('path');

function resolve (dir) {
  return path.join(__dirname, dir)
}

module.exports = defineConfig({
  transpileDependencies: true,
  productionSourceMap: false,
  filenameHashing: false,
  assetsDir: 'assets',
  outputDir: 'dist',
  publicPath:'/',
  chainWebpack: (config) => {
    config.resolve.alias
    .set('@', resolve('src'))
    .set("assets", resolve("src/assets"))
    .set("components", resolve("src/components"))
    .set("utils", resolve("utils"))
  },
  css: {
    loaderOptions: {
      postcss: {
        postcssOptions:{
          plugins: [
            require('postcss-pxtorem')({
              rootValue: 37.5, // 设计稿宽度的1/10，例如设计稿为375px，则rootValue为37.5
              propList: ['*'], // 可以从px更改为rem的属性
              // 选择器黑名单，忽略转换正则匹配项（选择器）
              selectorBlackList: [],
              minPixelValue: 2 // 设置要替换的最小像素值
            })
          ]
        }
      }
    }
  },
  configureWebpack:{
    output: {
      library: `${packageName}-[name]`,
      libraryTarget: 'umd',
      chunkLoadingGlobal: `webpackJsonp_${packageName}`,
    }
  }
})
